<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    b页面
    <script>
        //b中接收a的参数
        window.onmessage = function (ev) {
            console.log(ev.data);//a的参数
            console.log(ev.origin);//传进来参数的url
            setTimeout(() => {
                if (ev.data === "我是a的信息") {
                //b拿到a的参数后，再返回给a数据
                ev.source.postMessage('我是b返回给a的数据', ev.origin)
            }
            }, 1000);
          

        }
    </script>
</body>

</html>